package com.twu.biblioteca;

/**
 * Created by dmortime on 07/03/2014.
 */
public class ListAvailableBooksMenu implements IMenu {
    private OutputWriter outputWriter;
    private InputReader inputReader;
    private Library library;
    private Customer customer;
    
    public ListAvailableBooksMenu(OutputWriter outputWriter, InputReader inputReader, Library library, Customer customer) {
        this.outputWriter = outputWriter;
        this.inputReader = inputReader;
        this.library = library;
        this.customer = customer;
    }

    public void display() {
        outputWriter.writeLines("We have the following books available:");
        for(Book book: library.availableBooks()) {
            outputWriter.writeLines(book.getTitle());
        }
    }

    public IMenu nextMenu() {
        if (customer != null) {
            return new MainMenuWithLoggedInCustomer(outputWriter, inputReader, library, customer);
        } else {
            return new MainMenuWithoutLoggedInCustomer(outputWriter, inputReader, library);
        }
    }
}
